//
//  CreateControlTool.m
//  TheVideoClip
//
//  Created by 北斗君合MacMini on 2018/3/30.
//  Copyright © 2018年 北斗君合MacMini. All rights reserved.
//

#import "CreateControlTool.h"

@implementation CreateControlTool

/**
 根据背景颜色创建view
 
 @param backgroundColor 背景颜色
 @return view
 */
+ (UIView *)getViewWithBackgroundColor:(UIColor *)backgroundColor {
    UIView *view = [[UIView alloc] init];
    view.backgroundColor = backgroundColor;
    return view;
}

/**
 根据label的各种属性创建label
 
 @param text 文字
 @param textColor 文字颜色
 @param fontSize 文字大小
 @return label
 */
+ (UILabel *)getLabelWithText:(NSString *)text textColor:(UIColor *)textColor fontSize:(CGFloat)fontSize {
    UILabel *label = [[UILabel alloc] init];
    label.text = text;
    label.textColor = textColor;
    label.font = [UIFont systemFontOfSize:fontSize];
    return label;
}

/**
 根据label的各种属性创建label
 
 @param text 文字
 @param numberLines 行数
 @param textColor 文字颜色
 @param fontSize 文字大小
 @param textAlignment 对齐方式
 @return label
 */
+ (UILabel *)getLabelWithText:(NSString *)text numberLines:(NSUInteger)numberLines textColor:(UIColor *)textColor fontSize:(CGFloat)fontSize textAlignment:(NSTextAlignment)textAlignment {
    UILabel *label = [self getLabelWithText:text textColor:textColor fontSize:fontSize];
    label.numberOfLines = numberLines;
    label.textAlignment = textAlignment;
    return label;
}

/**
 创建button
 
 @param normalTitle 标题
 @param normalTitleColor 标题颜色
 @param fontSize 标题大小
 @return button
 */
+ (UIButton *)getButtonWithNormalTitle:(NSString *)normalTitle normalTitleColor:(UIColor *)normalTitleColor fontSize:(CGFloat)fontSize target:(id)target action:(SEL)action {
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitle:normalTitle forState:UIControlStateNormal];
    [button setTitleColor:normalTitleColor forState:UIControlStateNormal];
    button.titleLabel.font = [UIFont systemFontOfSize:fontSize];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return button;
}

/**
 创建textField

 @param fontSize 字体大小
 @param textColor 字体颜色
 @param placeholder 水印文字
 @return textField
 */
+ (UITextField *)getTextFieldWithTextFontSize:(CGFloat)fontSize textColor:(UIColor *)textColor placeholder:(NSString *)placeholder {
    UITextField *textField = [[UITextField alloc] init];
    textField.textColor = textColor;
    textField.font = [UIFont systemFontOfSize:fontSize];
    textField.autocorrectionType = UITextAutocorrectionTypeNo;
    textField.placeholder = placeholder;
    return textField;
}

@end
